<!-- TabBar 文章资讯 -->
<template>
	<view>
		<cu-custom bgColor="bg-white" :isBack="true">
			<block slot="backText">返回</block>
			<block slot="content">申请记录</block>
		</cu-custom>

		<view class="cu-card article card">
			<view class="bg-white padding ">
				<u-search placeholder="申请单位" v-model="keyword" @search="getData()" @custom="getData"></u-search>
			</view>
			<view class="cu-item shadow-warp borderBottom" v-for="(item, index) in newsList" :key="index" @click="goNews(item.id)">
				<view class="title">
					<view class="text-cut">申请单位：{{ item.orgName }}</view>
				</view>
				<view class="content">
					<view class="desc">
						<view class="text-content">
							负责人：{{ item.principalName }}
							<view class="text-red">
								<text v-if="item.status=='0'">状态：待分配</text>
								<text  v-if="item.status=='1'">状态：已分配</text>
								<text  v-if="item.status=='2'">状态：已拒绝</text>
								</view>
						</view>
						<view class="margin-top-xs">
							<view class="text-gray light sm round ">申请时间：{{ item.time }}</view>
							<view class="text-gray">
								<text>租借时间：{{ item.startTime }}-{{ item.endTime }}</text>
							</view>
						</view>
					</view>
				</view>
			</view>
		</view>
	</view>
</template>

<script>
import { getApplyList } from '@/api/main.js';
export default {
	data() {
		return {
			keyword:'',
			TabCur: 0,
			scrollLeft: 0,
			newsList: '',
			navTop: [
				{
					id: 1,
					title: '全部'
				},
				{
					id: 2,
					title: 'UI设计'
				},
				{
					id: 3,
					title: 'Web前端'
				},
				{
					id: 4,
					title: 'Java后台'
				},
				{
					id: 5,
					title: '面试精选'
				},
				{
					id: 6,
					title: '技术前沿'
				},
				{
					id: 7,
					title: '更多资讯'
				}
			]
		};
	},
	mounted() {
		this.getData();
	},
	methods: {
		getData() {
			let data ={
				orgName:this.keyword,
				pageSize:1000,
				column: "createTime",
				order: "desc"
			}
			getApplyList(data).then(res => {
				console.log(res.data);
				this.newsList = res.data.result.records;
			});

			// let opts = {
			// 	url: 'json/newsListe.json',
			// 	method: 'get'
			// };
			// uni.showLoading({
			// 	title: '加载中'
			// });
			// request.httpRequest(opts).then(res => {
			// 	// console.log(res);
			// 	uni.hideLoading();
			// 	if (res.statusCode == 200) {
			// 		this.newsList = res.data.data;
			// 		console.log(this.newsList);
			// 	} else {
			// 		console.log('数据请求错误～');
			// 	}
			// });
		},
		tabSelect(e) {
			this.TabCur = e.currentTarget.dataset.id;
			this.scrollLeft = (e.currentTarget.dataset.id - 1) * 60;
		},
		goNews(id) {
			uni.navigateTo({
				url: '/pages/classroom/detail?id=' + id
			});
		}
	}
};
</script>

<style lang="scss" scoped>
.borderBottom {
	border-bottom: 1px solid #f2f2f2;
}
</style>
